package com.som.beanconvert.data4.input;

import java.util.List;

import com.som.bean.IpAddressBase;
import com.som.bean.data4.input.SzCityIpAddressinfo;
import com.som.beanconvert.FileDataParseInputInf;
import com.som.beanconvert.FileRowDataParseProcessInf;
import com.som.util.IpAddressUtil;

/**
 * 苏州地市地址信息
 * 
 * @author liujun
 * @date 2016年5月10日
 * @verion 0.0.1
 */
public class SzCityIpAddressinfoFileInput extends IpAddressBase implements FileDataParseInputInf<SzCityIpAddressinfo>,
		FileRowDataParseProcessInf<SzCityIpAddressinfo, String> {

	public SzCityIpAddressinfo getMsginfo(String dataRow) {
		if (null != dataRow) {
			String[] line = dataRow.split("\t");
			if (null != line && line.length == 2) {
				SzCityIpAddressinfo szcity = new SzCityIpAddressinfo();

				szcity.setIpaddress(line[0]);
				szcity.setIpEnd(line[1]);

				return szcity;
			}
		}

		return null;
	}

	public void parseRowDataProcess(SzCityIpAddressinfo t, List<String> result, List<String> cityList) {

		if (null != t) {
			// 将ip段转化为ip
			List<String> ipList = IpAddressUtil.getIpListBySecation(t.getIpaddress(), t.getIpEnd());

			if (null != ipList && !ipList.isEmpty()) {
				cityList.addAll(ipList);
			}
		}

	}

}
